using UnityEngine;
using UnityEngine.UI;

/// <summary>
/// 转盘的单个Item
/// </summary>
public class TurntableItem : MonoBehaviour
{
    [SerializeField] private Image mBgImg;
    [SerializeField] private Text mItemNumTxt;
    public int ItemNum;
    private const string FinalNumStr = "100";

    /// <summary> 初始化Item </summary>
    public void SetItem(bool show, int num = 0)
    {
        gameObject.SetActive(true);
        mItemNumTxt.text = show ? num.ToString() : "";
        ItemNum = num;
        mBgImg.color = Color.white;
    }

    /// <summary> 刷新Item颜色 </summary>
    public void RefreshItem(Color tarColor)
    {
        mBgImg.color = tarColor;
    }
    
    /// <summary> 刷新Item颜色和数字 </summary>
    public void RefreshItemAndNum(Color tarColor)
    {
        mBgImg.color = tarColor;
        mItemNumTxt.text = ItemNum.ToString();
    }

    /// <summary> 转盘停止 </summary>
    public void ItemFinished()
    {
        RefreshItem(Color.green);
        mItemNumTxt.text = FinalNumStr;
    }
}
